package com.lancoo.znbkxx.teacher.ui.fragment

import android.content.Intent
import android.graphics.Color
import android.graphics.Typeface
import android.os.Bundle
import android.text.Html
import android.view.View
import android.view.animation.TranslateAnimation
import android.widget.LinearLayout
import android.widget.RelativeLayout
import androidx.recyclerview.widget.LinearLayoutManager
import com.github.mikephil.charting.data.PieDataSet
import com.github.mikephil.charting.data.PieEntry
import com.lancoo.znbkxx.teacher.Ext
import com.lancoo.znbkxx.teacher.R
import com.lancoo.znbkxx.teacher.aibkTestCoach.aibkTools.LancooMethod
import com.lancoo.znbkxx.teacher.aibkTestCoach.aibkTools.MyToast
import com.lancoo.znbkxx.teacher.aibkTestCoach.kBase.KBaseFragment
import com.lancoo.znbkxx.teacher.aibkTestCoach.networkRequest.bindLifeCycle
import com.lancoo.znbkxx.teacher.aibkTestCoach.networkRequest.entity.*
import com.lancoo.znbkxx.teacher.aibkTestCoach.networkRequest.viewModel.MarkViewModel
import com.lancoo.znbkxx.teacher.aibkTestCoach.studyAnalysis.StudyAnalysisActivity
import com.lancoo.znbkxx.teacher.diagnosis.StuDiagnosisActivity
import com.lancoo.znbkxx.teacher.ui.adapter.*
import com.lancoo.znbkxx.teacher.ui.dialog.*
import com.lancoo.znbkxx.teacher.ui.mpAndroidChart.LineChartSpeedManager
import com.lancoo.znbkxx.teacher.ui.mpAndroidChart.LineChartTimeManager
import com.lancoo.znbkxx.teacher.ui.mpAndroidChart.PieChartView
import com.lancoo.znbkxx.teacher.ui.mpAndroidChart.myPie.MyPieEntry
import com.lancoo.znbkxx.teacher.utils.ButtonUtils
import com.lancoo.znbkxx.teacher.utils.DensityUtils
import com.lancoo.znbkxx.teacher.widget.MyLayoutManager
import kotlinx.android.synthetic.main.aibk_adapter_item_cognitive_diagnosis_scale.view.*
import kotlinx.android.synthetic.main.aibk_adapter_item_estimate_grade_scale.view.*
import kotlinx.android.synthetic.main.aibk_adapter_item_language_ability_scale.view.*
import kotlinx.android.synthetic.main.fragment_cognitive_diagnosis.view.*
import kotlinx.android.synthetic.main.include_layout_cognitive_diagnosis_part1.view.*
import kotlinx.android.synthetic.main.include_layout_cognitive_diagnosis_part2.view.*
import kotlinx.android.synthetic.main.include_layout_cognitive_diagnosis_part3.view.*
import kotlinx.android.synthetic.main.include_layout_cognitive_diagnosis_part4.*
import kotlinx.android.synthetic.main.include_layout_cognitive_diagnosis_part4.view.*
import kotlinx.android.synthetic.main.include_layout_cognitive_diagnosis_part5.view.*
import kotlinx.android.synthetic.main.include_layout_cognitive_diagnosis_part6.view.*
import kotlinx.android.synthetic.main.include_layout_cognitive_diagnosis_part7.*
import kotlinx.android.synthetic.main.include_layout_cognitive_diagnosis_part7.view.*
import kotlinx.android.synthetic.main.include_layout_cognitive_diagnosis_part8.*
import kotlinx.android.synthetic.main.include_layout_cognitive_diagnosis_part8.view.*
import org.koin.androidx.viewmodel.ext.android.viewModel
import java.math.BigDecimal
import java.util.*


/**
 * @author : wangguolong
 * @date   : 2020/12/09
 * @desc   :
 */
class CognitiveDiagnosisFragment : KBaseFragment(), View.OnClickListener {

    companion object {
        private const val TITLE = "title"
        fun newInstance(title: String): CognitiveDiagnosisFragment {
            val fragment = CognitiveDiagnosisFragment()
            val bundle = Bundle()
            bundle.putString(TITLE, title)
            fragment.arguments = bundle
            return fragment
        }
    }

    private var rootView: View? = null
    private val mViewModel: MarkViewModel by viewModel()
    private var classKnowledgeAreaInfor: ClassKnowledgeAreaInfor? = null//知识点域详情
    private var classEstimateGradeInfor: ClassEstimateGradeInfor? = null//预估成绩详情
    private var classCognitiveDiagnosisInfor: ClassCognitiveDiagnosisInfor? = null//认知指数详情
    private var classStuCognitiveHonorRollListInfor: ClassStuCognitiveHonorRollListInfor? = null//班级认知荣誉榜
    private var classStuGradeDistributionInfor: ClassStuGradeDistributionInfor? = null//学生预估成绩分数段分布图
    private var classStuNumUpDownInfor: ClassStuNumUpDownInfor? = null////学生预估成绩分学生进步退步详情
    private var classStuCognitiveDiagnosisInfor: ClassStuCognitiveDiagnosisInfor? = null//认知指数分布图对应人数数据
    private var classVocablaryDiagnosisInfor: ClassVocablaryDiagnosisInfor? = null//词汇认知主界面数据
    private var classVocabularyMasterDistribInfor: ClassVocabularyMasterDistribInfor? = null//班级词汇掌握分布数据
    private var classGrammarDiagnosisInfor: ClassGrammarDiagnosisInfor? = null//班级语法认知主界面
    private var classGrammarMasterDistribInfor: ClassGrammarMasterDistribInfor? = null;//班级语法量掌握分布数据
    private var classLanguageAbilityInfor: ClassLanguageAbilityInfor? = null//班级语言能力分布数据
    private var classStuLanguageAbilityInfor: ClassStuLanguageAbilityInfor? = null//班级学生能力维度弹窗数据
    private var classAnswertraitInfor: ClassAnswertraitInfor? = null//班级做题特点主界面信息
    private var classStudyFeature: ClassStudyFeature? = null//班级学习特点
    private var classStudyAdviceInfor: ClassStudyAdviceInfor? = null//班级学习建议
    private var mLineChartTimeManager: LineChartTimeManager? = null
    private var mLineChartSpeedManager: LineChartSpeedManager? = null

    override fun createLayout(): Int {
        return R.layout.fragment_cognitive_diagnosis
    }

    override fun initView(view: View?) {

        rootView = view

        rootView!!.RlEmptyDiagnosis.visibility = View.VISIBLE
        rootView!!.RlEmptyClassDiagnosis.visibility = View.GONE
        rootView!!.RlDevelopingDiagnosis.visibility = View.VISIBLE
        rootView!!.RlFullDiagnosis.visibility = View.GONE
        rootView!!.TvClassDiagnosisName.text = Ext.COURSE_CLASSNAME +"认知诊断报告"
        rootView!!.TvClassDiagnosisName.typeface = Typeface.createFromAsset(requireContext().assets, "fonts/cool_black.TTF")

//        mViewModel.getIsOpenClassRZZD_App()
//                .doOnSubscribe {
//                }.bindLifeCycle(this)
//                .subscribe({
//                    if (it.code == 1) {
//                        if (it.data) {
//                            rootView!!.RlEmptyDiagnosis.visibility = View.GONE
//                            rootView!!.RlFullDiagnosis.visibility = View.VISIBLE
//
//                            //显示班级名称
//                            rootView!!.TvCourseClass.text = Ext.COURSE_CLASSNAME
//                            rootView!!.TvCourseClass.typeface = Typeface.createFromAsset(requireContext().assets,
//                                    "fonts/cool_black.TTF")
//                            rootView!!.TvTitleReport.typeface = Typeface.createFromAsset(requireContext().assets,
//                                    "fonts/cool_black.TTF")
//                            //显示知识点域数值
//                            showKnowledgeAreaView()
////                            rootView!!.TvKnowledgeAreaCount.setOnClickListener(this)
//
//                            //查看个人认知诊断
//                            rootView!!.TvCognitiveDiagnosisPersonal.setOnClickListener(this)
//
//                            //显示认知指数说明
//                            rootView!!.IvExplainRzzs.setOnClickListener(this)
//                            //显示认知荣誉榜
//                            rootView!!.IvHonorRoll.isClickable = false
//                            rootView!!.IvHonorRoll.setOnClickListener(this)
//                            //显示认知指数模块内容
//                            showCognitiveDiagnosisView()
//                            rootView!!.RlCognitionChangeUpView.setOnClickListener(this)
//                            rootView!!.RlCognitionChangeDownView.setOnClickListener(this)
//
//                            //显示班级预估成绩说明
//                            rootView!!.IvExplainYgcj.setOnClickListener(this)
//                            //显示预估成绩模块内容
//                            showEstimateGradeView()
//                            rootView!!.RlAverageGradeChangeUpView.setOnClickListener(this)
//                            rootView!!.RlAverageGradeChangeDownView.setOnClickListener(this)
//
//                            //显示词汇认知主界面模块内容
//                            rootView!!.IvExplainChrz.setOnClickListener(this)
//                            showVocablaryDiagnosisView()
//
//                            //语法认知主界面
//                            rootView!!.IvExplainYfrz.setOnClickListener(this)
//                            showGrammarDiagnosisView()
//
//                            //语言能力堆叠柱状图
//                            rootView!!.IvExplainYynl.setOnClickListener(this)
//                            showLanguageAbilityView()
//
//                            //显示做题特点说明
//                            rootView!!.IvExplainZttd.setOnClickListener(this)
//                            //做题特点柱状图
//                            showAnswerTraitView()
//
//                            //显示学习特点说明
//                            rootView!!.IvExplainXxtd.setOnClickListener(this)
//                            rootView!!.BtnStudyLength.setOnClickListener(this)
//                            rootView!!.BtnStudySpeed.setOnClickListener(this)
//                            rootView!!.BtnStudyLength.isSelected = true
//                            rootView!!.BtnStudySpeed.isSelected = false
//                            rootView!!.RlStudyLengthView.visibility = View.VISIBLE
//                            rootView!!.RlStudySpeedView.visibility = View.GONE
//                            //学习特点曲线图
//                            showStudyFeature()
//
//                            //班级学习建议
//                            showStudyAdviceView()
//
//                        } else {
//                            rootView!!.RlEmptyDiagnosis.visibility = View.VISIBLE
//                            rootView!!.TvEmptyDiagnoseMessage.typeface = Typeface.createFromAsset(requireContext().assets, "fonts/happy.ttf")
//                            rootView!!.RlFullDiagnosis.visibility = View.GONE
//                            showEmptyViewIsOpenStuRzzd()
//                        }
//
//                    } else {
//                        MyToast.showToast(it.message)
//                    }
//                }, {
//                    MyToast.showToast(it.message)
//                })

    }

    private fun showEmptyViewIsOpenStuRzzd() {
        mViewModel.getIsChangeStu_App()
                .doOnSubscribe {
                }.bindLifeCycle(this)
                .subscribe({
                    if (it.code == 1) {
                        if (it.data.toString().isEmpty()) {
                            rootView!!.BtnGoToStuRzzd.visibility = View.GONE
                        } else {
                            rootView!!.BtnGoToStuRzzd.visibility = View.VISIBLE
                            rootView!!.BtnGoToStuRzzd.setOnClickListener(this)
                        }
                    } else {
                        MyToast.showToast(it.message)
                    }
                }, {
                    MyToast.showToast(it.message)
                })
    }

    //显示知识点域切换文字
    private fun showZsdAreaTextView(ZsdAreaParentTxt: String, ZsdAreaNum: String) {
        val layout = MyLayoutManager()
        layout.isAutoMeasureEnabled = true //必须，防止recyclerview高度为wrap时测量item高度0
        rootView!!.RvKnowledgeAreaCount.layoutManager = layout
        val adapter = AibkKnowledgeAreaCountAdapter(requireContext(), ZsdAreaParentTxt, ZsdAreaNum)
        adapter.setClickListener(object : AibkKnowledgeAreaCountAdapter.OnClickListener {
            override fun onClick() {
//                MyToast.showToast("点击了知识点域切换按钮")
                //选择切换知识点域数据
                if (classKnowledgeAreaInfor!!.size > 0) {
                    val dialogChangeKnowledgeArea = DialogChangeKnowledgeArea(activity, classKnowledgeAreaInfor!!)
                    dialogChangeKnowledgeArea.setClickListener(object : DialogChangeKnowledgeArea.OnClickListener {
                        override fun onClickWhich(pos: Int) {

                            if (Ext.GLOBAL_GRADE_STU == "K6" || Ext.GLOBAL_GRADE_STU == "K7" || Ext.GLOBAL_GRADE_STU == "K8" || Ext.GLOBAL_GRADE_STU == "K9") {
                                Ext.STAGE_NO = "B"
                            } else if (Ext.GLOBAL_GRADE_STU == "K10" || Ext.GLOBAL_GRADE_STU == "K11" || Ext.GLOBAL_GRADE_STU == "K12") {
                                Ext.STAGE_NO = "C"
                            }
                            var parentTitlle = ""
                            if (pos == 0) {
                                if (Ext.STAGE_NO == "B") {
                                    parentTitlle = "以下诊断报告基于中考教材及大纲的"
                                } else {
                                    parentTitlle = "以下诊断报告基于高考教材及大纲的"
                                }
                                zsdArea = "A"
                            } else if (pos == 1) {
                                if (Ext.STAGE_NO == "B") {
                                    parentTitlle = "以下诊断报告基于中考较常考的"
                                } else {
                                    parentTitlle = "以下诊断报告基于高考较常考的"
                                }
                                zsdArea = "B"
                            } else if (pos == 2) {
                                if (Ext.STAGE_NO == "B") {
                                    parentTitlle = "以下诊断报告基于中考历年考试的所有"
                                } else {
                                    parentTitlle = "以下诊断报告基于高考历年考试的所有"
                                }
                                zsdArea = "C"
                            }
                            zsdNumber = classKnowledgeAreaInfor!![pos].Number
                            adapter.changeKnowledgeAreaCount(parentTitlle, zsdNumber.toString())

                            /**********************选择知识点域后刷新相应图表************************************/
                            //显示认知指数模块内容
                            showCognitiveDiagnosisView()
                            //显示词汇认知主界面模块内容
                            showVocablaryDiagnosisView()
                            //语法认知主界面
                            showGrammarDiagnosisView()
                            //班级学习建议
                            showStudyAdviceView()
                        }
                    })
                    dialogChangeKnowledgeArea.show()
                } else {
                    MyToast.showToast("未获取到知识点域相关信息,请稍后重试!")
                }
            }

            override fun onClickAnother() {
                //点击了查看班级学情分析报告
//                MyToast.showToast("点击了查看班级学情分析报告")
                startActivity(Intent(requireContext(), StudyAnalysisActivity::class.java))

            }
        })
        rootView!!.RvKnowledgeAreaCount.adapter = adapter
    }

    //显示知识点域
    private var zsdArea: String = "A"
    private var zsdNumber: Int = 0
    private fun showKnowledgeAreaView() {
        mViewModel.getZsdArea_App()
                .doOnSubscribe {
                }.bindLifeCycle(this)
                .subscribe({
                    if (it.code == 1) {
                        classKnowledgeAreaInfor = it.data
                        val inofrSize = classKnowledgeAreaInfor!!.size
                        for (i in 0 until inofrSize) {
                            if (i == 0) {
                                classKnowledgeAreaInfor!![0].isSelected = true
                            } else {
                                classKnowledgeAreaInfor!![i].isSelected = false
                            }
                        }

                        zsdNumber = classKnowledgeAreaInfor!![0].Number

                        if (Ext.GLOBAL_GRADE_STU == "K6" ||Ext.GLOBAL_GRADE_STU == "K7" || Ext.GLOBAL_GRADE_STU == "K8" || Ext.GLOBAL_GRADE_STU == "K9") {
                            Ext.STAGE_NO = "B"
                        } else if (Ext.GLOBAL_GRADE_STU == "K10" || Ext.GLOBAL_GRADE_STU == "K11" || Ext.GLOBAL_GRADE_STU == "K12") {
                            Ext.STAGE_NO = "C"
                        }
                        var parentTitlle = ""
                        if (Ext.STAGE_NO == "B") {
                            parentTitlle = "以下诊断报告基于中考教材及大纲的"
                        } else {
                            parentTitlle = "以下诊断报告基于高考教材及大纲的"
                        }
                        showZsdAreaTextView(parentTitlle, zsdNumber.toString())
                    } else {
//                        MyToast.showToast(it.message)
                    }
                }, {
//                    MyToast.showToast(it.message)
                })

    }

    //显示班级预估成绩View
    private fun showEstimateGradeView() {
        mViewModel.getClassTotalScore_App()
                .doOnSubscribe {
                }.bindLifeCycle(this)
                .subscribe({
                    if (it.code == 1) {
                        classEstimateGradeInfor = it.data

                        val isOpen = classEstimateGradeInfor!!.IsOpen
                        if (isOpen) {
                            rootView!!.LlYgcjProgressView.visibility = View.VISIBLE
                            rootView!!.TvTitleEmptyYgcj.visibility = View.GONE
                            rootView!!.LlYgcjChartView.visibility = View.VISIBLE
                            //显示预估成绩
                            var avgClassScore = classEstimateGradeInfor!!.AvgClassScore
                            val a = BigDecimal(avgClassScore)
                            avgClassScore = a.setScale(0, BigDecimal.ROUND_HALF_UP).toDouble()
                            var fullScore = classEstimateGradeInfor!!.FullScore
                            val b = BigDecimal(fullScore)
                            fullScore = b.setScale(0, BigDecimal.ROUND_HALF_UP).toDouble()
                            val business = LancooMethod.getCorrectRate(avgClassScore, fullScore)
                            val c = BigDecimal(business * 100)
                            val businessProgress = c.setScale(0, BigDecimal.ROUND_HALF_UP).toInt()

                            if (business >= 0.9) {
                                rootView!!.IvIconYgcj.setImageResource(R.mipmap.aibk_icon_medals_a)
                            } else if (business >= 0.8) {
                                rootView!!.IvIconYgcj.setImageResource(R.mipmap.aibk_icon_medals_b)
                            }else if (business >= 0.7) {
                                rootView!!.IvIconYgcj.setImageResource(R.mipmap.aibk_icon_medals_c)
                            }else if (business >= 0.6) {
                                rootView!!.IvIconYgcj.setImageResource(R.mipmap.aibk_icon_medals_d)
                            } else {
                                rootView!!.IvIconYgcj.setImageResource(R.mipmap.aibk_icon_medals_e)
                            }
                            rootView!!.TvAverageGrade.text = Html.fromHtml(resources.getString(R.string.aibk_class_estimate_grade_average_score, LancooMethod.killlingDouble(avgClassScore)))
                            rootView!!.TvFullGrade.text = Html.fromHtml(resources.getString(R.string.aibk_class_estimate_grade_full_score, LancooMethod.killlingDouble(fullScore)))
                            rootView!!.PbAverageGrade.progress = businessProgress

                            //显示平均预估成绩###1111111####
                            var strChangeScore = ""
                            val changeScore = classEstimateGradeInfor!!.ChangeScore
                            if (changeScore < 0) {
                                strChangeScore = "下降" + LancooMethod.killlingDouble(Math.abs(changeScore)) + "分"
                            } else if (changeScore == 0.0) {
                                strChangeScore = "无变化"
                            } else if (changeScore > 0) {
                                strChangeScore = "提升" + LancooMethod.killlingDouble(changeScore) + "分"
                            }
                            rootView!!.TvAverageGradeChange.text = strChangeScore
                            rootView!!.TvAverageGradeChange.typeface = Typeface.createFromAsset(requireContext().assets,
                                    "fonts/cool_black.TTF")
                            //显示学生进步人数###222222####
                            val upTotalNum = classEstimateGradeInfor!!.UpTotalNum
                            val avgUpScore = classEstimateGradeInfor!!.AvgUpScore
                            rootView!!.TvAverageGradeChangeUpNum.text = Html.fromHtml(resources.getString(R.string.aibk_class_estimate_grade_up_num, upTotalNum))
                            rootView!!.TvAverageGradeChangeUpScore.text = "平均提升" + LancooMethod.killlingDouble(avgUpScore) + "分"
                            rootView!!.TvAverageGradeChangeUpScore.typeface = Typeface.createFromAsset(requireContext().assets,
                                    "fonts/cool_black.TTF")
                            //显示学生退步人数###333333####
                            val downTotalNum = classEstimateGradeInfor!!.DownTotalNum
                            val avgDownScore = classEstimateGradeInfor!!.AvgDownScore
                            rootView!!.TvAverageGradeChangeDownNum.text = Html.fromHtml(resources.getString(R.string.aibk_class_estimate_grade_down_num, downTotalNum))
                            rootView!!.TvAverageGradeChangeDownScore.text = "平均降低" + LancooMethod.killlingDouble(avgDownScore) + "分"
                            rootView!!.TvAverageGradeChangeDownScore.typeface = Typeface.createFromAsset(requireContext().assets,
                                    "fonts/cool_black.TTF")

                            //显示预估成绩分布图
                            var maxDistreNum = 0
                            val mapSize = classEstimateGradeInfor!!.ScoreIndexMap.size
                            for (i in 0 until mapSize) {
                                val distreNum = classEstimateGradeInfor!!.ScoreIndexMap[i].DistreNum
                                if (maxDistreNum < distreNum) {
                                    maxDistreNum = distreNum
                                }
                            }
                            if (maxDistreNum <= 4) {
                                maxDistreNum = 4
                            } else {
                                maxDistreNum = (maxDistreNum / 4) * 4 + 4
                            }
                            rootView!!.TvGradeScore0.text = ((maxDistreNum / 4) * 0).toString()
                            rootView!!.TvGradeScore1.text = ((maxDistreNum / 4) * 1).toString()
                            rootView!!.TvGradeScore2.text = ((maxDistreNum / 4) * 2).toString()
                            rootView!!.TvGradeScore3.text = ((maxDistreNum / 4) * 3).toString()
                            rootView!!.TvGradeScore4.text = ((maxDistreNum / 4) * 4).toString()

                            var manager1 = LinearLayoutManager(activity)
                            manager1.orientation = LinearLayoutManager.HORIZONTAL
                            rootView!!.RvEstimateGrade.layoutManager = manager1
                            val mAdapter1 = AibkEstimateGradeAdapter(activity, classEstimateGradeInfor!!, maxDistreNum)
                            mAdapter1.setClickListener(object : AibkEstimateGradeAdapter.OnClickListener {
                                override fun onClick(pos: Int) {
                                    //显示学生成绩分布弹窗（班级预估成绩）
                                    showDialogStuScoreDistre(pos)
                                }
                            })
                            rootView!!.RvEstimateGrade.adapter = mAdapter1
                        } else {
                            rootView!!.IvIconYgcj.setImageResource(R.mipmap.aibk_icon_class_empty_ygcj)
                            rootView!!.LlYgcjProgressView.visibility = View.GONE
                            rootView!!.TvTitleEmptyYgcj.visibility = View.VISIBLE
                            rootView!!.LlYgcjChartView.visibility = View.GONE
                        }

                    } else {
//                        MyToast.showToast(it.message)
                    }
                }, {
//                    MyToast.showToast(it.message)
                })

    }

    //显示认知指数View
    private fun showCognitiveDiagnosisView() {
        mViewModel.getClassCognitiveIndex_App(zsdArea)
                .doOnSubscribe {
                }.bindLifeCycle(this)
                .subscribe({
                    if (it.code == 1) {
                        classCognitiveDiagnosisInfor = it.data

                        //显示班级平均任职指数
                        val honorIsOpen = classCognitiveDiagnosisInfor!!.HonorIsOpen
                        val fullIndex = classCognitiveDiagnosisInfor!!.FullIndex
                        val classIndex = classCognitiveDiagnosisInfor!!.ClassIndex
                        val business = LancooMethod.getCorrectRate(classIndex, fullIndex)
                        val c = BigDecimal(business * 100)
                        val businessProgress = c.setScale(0, BigDecimal.ROUND_HALF_UP).toInt()

                        //显示认知荣誉榜入口按钮
                        if (honorIsOpen) {
                            rootView!!.IvHonorRoll.setImageResource(R.mipmap.aibk_button_class_honor_roll_on)
                            rootView!!.IvHonorRoll.isClickable = true
                        } else {
                            rootView!!.IvHonorRoll.setImageResource(R.mipmap.aibk_button_class_honor_roll_off)
                            rootView!!.IvHonorRoll.isClickable = false
                        }
                        if (business >= 0.8) {
                            rootView!!.IvIconRzzs.setImageResource(R.mipmap.aibk_icon_medals_a)
                        } else if (business >= 0.6) {
                            rootView!!.IvIconRzzs.setImageResource(R.mipmap.aibk_icon_medals_b)
                        } else if (business >= 0.4) {
                            rootView!!.IvIconRzzs.setImageResource(R.mipmap.aibk_icon_medals_c)
                        }  else {
                            rootView!!.IvIconRzzs.setImageResource(R.mipmap.aibk_icon_medals_d)
                        }
                        rootView!!.TvAverageRzzs.text = Html.fromHtml(resources.getString(R.string.aibk_class_estimate_grade_average_score, LancooMethod.killlingDouble(classIndex)))
                        rootView!!.TvFullRzzs.text = Html.fromHtml(resources.getString(R.string.aibk_class_estimate_grade_full_score, LancooMethod.killlingDouble(fullIndex)))
                        rootView!!.PbAverageRzzs.progress = businessProgress

                        //显示班级认知指数###1111111####
                        var strChangeKnow = ""
                        val changeScore = classCognitiveDiagnosisInfor!!.ClassScoreUp
                        if (changeScore < 0) {
                            strChangeKnow = "下降" + LancooMethod.killlingDouble(Math.abs(changeScore)) + "分"
                        } else if (changeScore == 0.0) {
                            strChangeKnow = "无变化"
                        } else if (changeScore > 0) {
                            strChangeKnow = "提升" + LancooMethod.killlingDouble(changeScore) + "分"
                        }
                        rootView!!.TvCognitionChange.text = strChangeKnow
                        rootView!!.TvCognitionChange.typeface = Typeface.createFromAsset(requireContext().assets,
                                "fonts/cool_black.TTF")
                        //显示学生进步人数###222222####
                        val improveNum = classCognitiveDiagnosisInfor!!.ImproveNum
                        val improveScore = classCognitiveDiagnosisInfor!!.ImproveScore
                        rootView!!.TvCognitionChangeUpNum.text = Html.fromHtml(resources.getString(R.string.aibk_class_estimate_grade_up_num, improveNum))
                        rootView!!.TvCognitionChangeUpScore.text = "平均提升" + LancooMethod.killlingDouble(improveScore) + "分"
                        rootView!!.TvCognitionChangeUpScore.typeface = Typeface.createFromAsset(requireContext().assets,
                                "fonts/cool_black.TTF")
                        //显示学生退步人数###333333####
                        val fallNum = classCognitiveDiagnosisInfor!!.FallNum
                        val fallScore = classCognitiveDiagnosisInfor!!.FallScore
                        rootView!!.TvCognitionChangeDownNum.text = Html.fromHtml(resources.getString(R.string.aibk_class_estimate_grade_down_num, fallNum))
                        rootView!!.TvCognitionChangeDownScore.text = "平均降低" + LancooMethod.killlingDouble(fallScore) + "分"
                        rootView!!.TvCognitionChangeDownScore.typeface = Typeface.createFromAsset(requireContext().assets,
                                "fonts/cool_black.TTF")

                        //显示班级认知指数分布图
                        var maxDistreNum = 0
                        val mapSize = classCognitiveDiagnosisInfor!!.ClassIndexMap.size
                        for (i in 0 until mapSize) {
                            val distreNum = classCognitiveDiagnosisInfor!!.ClassIndexMap[i].DistreNum
                            if (maxDistreNum < distreNum) {
                                maxDistreNum = distreNum
                            }
                        }
                        if (maxDistreNum <= 4) {
                            maxDistreNum = 4
                        } else {
                            maxDistreNum = (maxDistreNum / 4) * 4 + 4
                        }
                        rootView!!.TvDiagnosisScore0.text = ((maxDistreNum / 4) * 0).toString()
                        rootView!!.TvDiagnosisScore1.text = ((maxDistreNum / 4) * 1).toString()
                        rootView!!.TvDiagnosisScore2.text = ((maxDistreNum / 4) * 2).toString()
                        rootView!!.TvDiagnosisScore3.text = ((maxDistreNum / 4) * 3).toString()
                        rootView!!.TvDiagnosisScore4.text = ((maxDistreNum / 4) * 4).toString()

                        var manager2 = LinearLayoutManager(activity)
                        manager2.orientation = LinearLayoutManager.HORIZONTAL
                        rootView!!.RvCognitiveDiagnosis.layoutManager = manager2
                        val mAdapter2 = AibkCognitiveDiagnosisAdapter(activity, classCognitiveDiagnosisInfor!!, maxDistreNum)
                        mAdapter2.setClickListener(object : AibkCognitiveDiagnosisAdapter.OnClickListener {
                            override fun onClick(pos: Int) {
                                //显示学生成绩分布弹窗（班级预估成绩）
                                showDialogStuDiagnosisDistre(pos)
                            }
                        })
                        rootView!!.RvCognitiveDiagnosis.adapter = mAdapter2

                    } else {
//                        MyToast.showToast(it.message)
                    }
                }, {
//                    MyToast.showToast(it.message)
                })
    }

    //显示学生成绩对应的提升与退步情况数据
    private fun showDialogStuScoreNumUpDownInfor(isUpScore: Boolean) {
        mViewModel.getStuNum_App()
                .doOnSubscribe {
                }.bindLifeCycle(this)
                .subscribe({
                    if (it.code == 1) {
                        classStuNumUpDownInfor = it.data

                        if (isUpScore) {
                            val upInfoSize = classStuNumUpDownInfor!!.StuUpList.size
                            if (upInfoSize > 0) {
                                val dialogEstimateGradeStuNumList = DialogEstimateGradeStuNumList(activity, classStuNumUpDownInfor!!, isUpScore)
                                dialogEstimateGradeStuNumList.show()
                            } else {
                                MyToast.showToast("暂无数据")
                            }
                        } else {
                            val downInfoSize = classStuNumUpDownInfor!!.StuDownList.size
                            if (downInfoSize > 0) {
                                val dialogEstimateGradeStuNumList = DialogEstimateGradeStuNumList(activity, classStuNumUpDownInfor!!, isUpScore)
                                dialogEstimateGradeStuNumList.show()
                            } else {
                                MyToast.showToast("暂无数据")
                            }
                        }

                    } else {
                        MyToast.showToast(it.message)
                    }
                }, {
                    MyToast.showToast(it.message)
                })
    }

    //显示学生预估成绩分布图单个分数段对应人数数据
    private fun showDialogStuScoreDistre(pos: Int) {
        mViewModel.getScoreDistre_App(pos)
                .doOnSubscribe {
                }.bindLifeCycle(this)
                .subscribe({
                    if (it.code == 1) {
                        classStuGradeDistributionInfor = it.data

                        val dialogEstimateGradeStuIntervalList = DialogEstimateGradeStuIntervalList(activity, classStuGradeDistributionInfor!!)
                        dialogEstimateGradeStuIntervalList.show()
                    } else {
                        MyToast.showToast(it.message)
                    }
                }, {
                    MyToast.showToast(it.message)
                })
    }

    //显示学生认知指数对应的提升与退步情况数据
    private fun showDialogStuCognitionNumUpDownInfor(flag: Int) {
        mViewModel.getRangeClassTableInfo_App(flag, zsdArea)
                .doOnSubscribe {
                }.bindLifeCycle(this)
                .subscribe({
                    if (it.code == 1) {
                        classStuCognitiveDiagnosisInfor = it.data

                        val classIndexTableSize = classStuCognitiveDiagnosisInfor!!.ClassIndexTable.size
                        if (classIndexTableSize > 0) {
                            //显示认知指数进步与退步的弹窗
                            val dialogCognitiveDiagnosisStuNumList = DialogCognitiveDiagnosisStuNumList(activity, classStuCognitiveDiagnosisInfor!!)
                            dialogCognitiveDiagnosisStuNumList.show()
                        } else {
                            MyToast.showToast("暂无数据")
                        }
                    } else {
                        MyToast.showToast(it.message)
                    }
                }, {
                    MyToast.showToast(it.message)
                })
    }

    //显示学生认知指数分布图单个指数段对应人数数据
    private fun showDialogStuDiagnosisDistre(flag: Int) {
        mViewModel.getRangeClassTableInfo_App(flag, zsdArea)
                .doOnSubscribe {
                }.bindLifeCycle(this)
                .subscribe({
                    if (it.code == 1) {
                        classStuCognitiveDiagnosisInfor = it.data

                        val dialogCognitiveDiagnosisStuIntervalList = DialogCognitiveDiagnosisStuIntervalList(activity, classStuCognitiveDiagnosisInfor!!)
                        dialogCognitiveDiagnosisStuIntervalList.setClickListener(object : DialogCognitiveDiagnosisStuIntervalList.OnClickListener {
                            override fun onClick(pos: Int) {
                                startActivity(Intent(requireContext(), StuDiagnosisActivity::class.java).apply {
                                    putExtra("zsdarea", zsdArea)
                                    putExtra("number", zsdNumber.toString())
                                    putExtra("stuId", classStuCognitiveDiagnosisInfor!!.ClassIndexTable[pos - 1].StuID)
                                    putExtra("moveTo", 2)// 0词汇认知 1语法认知 2:认知指数
                                })
                            }
                        })
                        dialogCognitiveDiagnosisStuIntervalList.show()
                    } else {
                        MyToast.showToast(it.message)
                    }
                }, {
                    MyToast.showToast(it.message)
                })
    }

    private fun showDialogStuHonorRollList() {
        mViewModel.getCognitiveIndexHonorRank_App(zsdArea)
                .doOnSubscribe {
                    rootView!!.RlGradeLoadingView.visibility = View.VISIBLE
                }.bindLifeCycle(this)
                .subscribe({
                    if (it.code == 1) {
                        rootView!!.RlGradeLoadingView.visibility = View.GONE
                        classStuCognitiveHonorRollListInfor = it.data
//
                        val dialogCognitiveHonorRollList = DialogCognitiveHonorRollList(activity, classStuCognitiveHonorRollListInfor!!)
                        dialogCognitiveHonorRollList.show()
                    } else {
                        MyToast.showToast(it.message)
                    }
                }, {
                    MyToast.showToast(it.message)
                })

    }

    //词汇认知弹窗界面
    private fun showVocablaryDialogView(flag: Int, typeStr: String) {
        mViewModel.getRangeClassVocabInfo_App(flag, typeStr, zsdArea)
                .doOnSubscribe {
                }.bindLifeCycle(this)
                .subscribe({
                    if (it.code == 1) {
                        classVocabularyMasterDistribInfor = it.data
//
                        val dialogClassVocabularyMasterDistribList = DialogVocabularyMasterDistribList(activity, flag, typeStr, classVocabularyMasterDistribInfor!!)
                        dialogClassVocabularyMasterDistribList.setClickListener(object : DialogVocabularyMasterDistribList.OnClickListener {
                            override fun onClick(pos: Int) {
                                startActivity(Intent(requireContext(), StuDiagnosisActivity::class.java).apply {
                                    putExtra("zsdarea", zsdArea)
                                    putExtra("number", zsdNumber.toString())
                                    putExtra("stuId", classVocabularyMasterDistribInfor!!.ClassVocabTable[pos - 1].StuID)
                                    putExtra("moveTo", 0)// 0词汇认知 1语法认知 2:认知指数
                                })
                            }
                        })
                        dialogClassVocabularyMasterDistribList.show()
                    } else {
                        MyToast.showToast(it.message)
                    }
                }, {
                    MyToast.showToast(it.message)
                })
    }

    //词汇认知主界面
    private fun showVocablaryDiagnosisView() {
        mViewModel.getClassVocablary_App(zsdArea)
                .doOnSubscribe {
                }.bindLifeCycle(this)
                .subscribe({
                    if (it.code == 1) {
                        classVocablaryDiagnosisInfor = it.data

                        var vocabularyMasterRank = ""//词汇掌握率
                        val totalConslusion = classVocablaryDiagnosisInfor!!.TotalConslusion
                        if (totalConslusion == 0) {
                            rootView!!.IvVocabularyMasterIcon.setImageResource(R.mipmap.aibk_icon_chrz_empty)
                            rootView!!.TvTitleVocabularyMaster.text =
                                    Html.fromHtml(resources.getString(R.string.aibk_class_vocabulary_master_rate_empty,
                                            "暂无诊断结果"))
                            rootView!!.TvSubHeadVocabulary.text = "班级学生词汇学习量较少,请督促学生抓紧学习"

                        } else {
                            val totalVocaMix = classVocablaryDiagnosisInfor!!.TotalVocaMix
                            val totalVocaMin = classVocablaryDiagnosisInfor!!.TotalVocaMin
                            val totalVocaMedium = classVocablaryDiagnosisInfor!!.TotalVocaMedium
                            if (totalConslusion == 1) {
                                rootView!!.IvVocabularyMasterIcon.setImageResource(R.mipmap.aibk_icon_chrz_c)
                                rootView!!.TvTitleVocabularyMaster.text =
                                        Html.fromHtml(resources.getString(R.string.aibk_class_vocabulary_master_rate_bad,
                                                "较差"))
                                rootView!!.TvSubHeadVocabulary.text =
                                        Html.fromHtml(resources.getString(R.string.aibk_class_vocabulary_master_small,
                                                (LancooMethod.killlingDouble(LancooMethod.formatDouble(totalVocaMin, 2) * 100)).toString()))

                            } else if (totalConslusion == 2) {
                                rootView!!.IvVocabularyMasterIcon.setImageResource(R.mipmap.aibk_icon_chrz_b)
                                rootView!!.TvTitleVocabularyMaster.text =
                                        Html.fromHtml(resources.getString(R.string.aibk_class_vocabulary_master_rate_good,
                                                "较好"))
                                rootView!!.TvSubHeadVocabulary.text = Html.fromHtml(resources.getString(R.string.aibk_class_vocabulary_master_big,
                                        LancooMethod.killlingDouble(LancooMethod.formatDouble(totalVocaMix, 2) * 100)))

                            } else if (totalConslusion == 3) {
                                rootView!!.IvVocabularyMasterIcon.setImageResource(R.mipmap.aibk_icon_chrz_a)
                                rootView!!.TvTitleVocabularyMaster.text =
                                        Html.fromHtml(resources.getString(R.string.aibk_class_vocabulary_master_rate_good,
                                                "较好"))
                                rootView!!.TvSubHeadVocabulary.text = Html.fromHtml(resources.getString(R.string.aibk_class_vocabulary_master_big,
                                        LancooMethod.killlingDouble(LancooMethod.formatDouble(totalVocaMix, 2) * 100)))

                            }
                        }


                        //显示词汇认知模块内容
                        var listenMaxStuNum = 0
                        for (i in 0 until 3) {
                            val masterStuNum = classVocablaryDiagnosisInfor!!.LVList[0].VocabMap[i].MasterStuNum
//                            if (masterStuNum > listenMaxStuNum) {
//                                listenMaxStuNum = masterStuNum
//                            }
                            listenMaxStuNum += masterStuNum
                        }
                        rootView!!.TvListenMaxStuNum.text = listenMaxStuNum.toString()
                        var manager03 = LinearLayoutManager(activity)
                        manager03.orientation = LinearLayoutManager.VERTICAL
                        rootView!!.RvListenVocabularyCount.layoutManager = manager03
                        val mAdapter03 = AibkListenVocabularyCountAdapter(activity, listenMaxStuNum, classVocablaryDiagnosisInfor!!)
                        mAdapter03.setClickListener(object : AibkListenVocabularyCountAdapter.OnClickListener {
                            override fun onClick(flag: Int) {
//                                MyToast.showToast("listen=="+flag)
                                showVocablaryDialogView(flag, "L")
                            }

                        })
                        rootView!!.RvListenVocabularyCount.adapter = mAdapter03

                        var readMaxStuNum = 0
                        for (i in 0 until 3) {
                            val masterStuNum = classVocablaryDiagnosisInfor!!.LVList[1].VocabMap[i].MasterStuNum
//                            if (masterStuNum > readMaxStuNum) {
//                                readMaxStuNum = masterStuNum
//                            }
                            readMaxStuNum += masterStuNum
                        }
                        rootView!!.TvReadMaxStuNum.text = readMaxStuNum.toString()
                        var manager04 = LinearLayoutManager(activity)
                        manager04.orientation = LinearLayoutManager.VERTICAL
                        rootView!!.RvReadVocabularyCount.layoutManager = manager04
                        val mAdapter04 = AibkReadVocabularyCountAdapter(activity, readMaxStuNum, classVocablaryDiagnosisInfor!!)
                        mAdapter04.setClickListener(object : AibkReadVocabularyCountAdapter.OnClickListener {
                            override fun onClick(flag: Int) {
//                                MyToast.showToast("read=="+flag)
                                showVocablaryDialogView(flag, "R")
                            }

                        })
                        rootView!!.RvReadVocabularyCount.adapter = mAdapter04
                    } else {
                        MyToast.showToast(it.message)
                    }
                }, {
                    MyToast.showToast(it.message)
                })
    }

    //语法认知主界面（饼图）
    private var pieChartEntity: PieChartView? = null
    private fun showGrammarDiagnosisView() {

        mViewModel.getClassGrammar_App(zsdArea)
                .doOnSubscribe {
                }.bindLifeCycle(this)
                .subscribe({
                    if (it.code == 1) {

                        classGrammarDiagnosisInfor = it.data

                        val conclusion = classGrammarDiagnosisInfor!!.Conclusion
                        if (conclusion == 0) {
                            rootView!!.IvGrammarMasterIcon.setImageResource(R.mipmap.aibk_icon_yfrz_empty)
                            rootView!!.TvTitleGrammarMaster.text =
                                    Html.fromHtml(resources.getString(R.string.aibk_class_grammar_master_rate_empty,
                                            "暂无诊断结果"))
                            rootView!!.TvSubHeadGrammar.text = "班级学生语法学习量较少,请督促学生抓紧学习"

                        } else {
                            val grammarMix = classGrammarDiagnosisInfor!!.GrammarMix
                            val grammarMedium = classGrammarDiagnosisInfor!!.GrammarMedium
                            val grammarMin = classGrammarDiagnosisInfor!!.GrammarMin
                            if (conclusion == 1) {
                                rootView!!.IvGrammarMasterIcon.setImageResource(R.mipmap.aibk_icon_yfrz_c)
                                rootView!!.TvTitleGrammarMaster.text =
                                        Html.fromHtml(resources.getString(R.string.aibk_class_grammar_master_rate_bad,
                                                "较差"))
                                rootView!!.TvSubHeadGrammar.text = Html.fromHtml(resources.getString(R.string.aibk_class_grammar_master_small,
                                        LancooMethod.killlingDouble(LancooMethod.formatDouble(grammarMin, 2) * 100)))
                            } else if (conclusion == 2) {
                                rootView!!.IvGrammarMasterIcon.setImageResource(R.mipmap.aibk_icon_yfrz_b)
                                rootView!!.TvTitleGrammarMaster.text =
                                        Html.fromHtml(resources.getString(R.string.aibk_class_grammar_master_rate_good,
                                                "较好"))
                                rootView!!.TvSubHeadGrammar.text = Html.fromHtml(resources.getString(R.string.aibk_class_grammar_master_big,
                                        LancooMethod.killlingDouble(LancooMethod.formatDouble(grammarMix, 2) * 100)))
                            } else if (conclusion == 3) {
                                rootView!!.IvGrammarMasterIcon.setImageResource(R.mipmap.aibk_icon_yfrz_a)
                                rootView!!.TvTitleGrammarMaster.text =
                                        Html.fromHtml(resources.getString(R.string.aibk_class_grammar_master_rate_good,
                                                "较好"))
                                rootView!!.TvSubHeadGrammar.text = Html.fromHtml(resources.getString(R.string.aibk_class_grammar_master_big,
                                        LancooMethod.killlingDouble(LancooMethod.formatDouble(grammarMix, 2) * 100)))
                            }

                        }

                        val colors = intArrayOf(Color.parseColor("#f9ad4f"),
                                Color.parseColor("#22d7bb"),
                                Color.parseColor("#00afff"),
                                Color.parseColor("#ffffff"))

                        val colorSum: MutableList<Int> = ArrayList()
                        val entries: ArrayList<PieEntry> = ArrayList<PieEntry>()

                        val masterStuNum0 = classGrammarDiagnosisInfor!!.GrammarMap[0].MasterStuNum
                        if (masterStuNum0 != 0) {
                            colors[0] = Color.parseColor("#f9ad4f")
                            colorSum.add(Color.parseColor("#f9ad4f"))

                            val pieEntry0 = PieEntry(masterStuNum0.toFloat(), masterStuNum0.toString() + "人")
                            entries.add(pieEntry0)
                        }

                        var masterStuNum1 = classGrammarDiagnosisInfor!!.GrammarMap[1].MasterStuNum
                        if (masterStuNum1 != 0) {
                            colors[1] = Color.parseColor("#22d7bb")
                            colorSum.add(Color.parseColor("#22d7bb"))
                            val pieEntry1 = PieEntry(masterStuNum1.toFloat(), masterStuNum1.toString() + "人")
                            entries.add(pieEntry1)
                        }

                        var masterStuNum2 = classGrammarDiagnosisInfor!!.GrammarMap[2].MasterStuNum
                        if (masterStuNum2 != 0) {
                            colors[2] = Color.parseColor("#00afff")
                            colorSum.add(Color.parseColor("#00afff"))
                            val pieEntry2 = PieEntry(masterStuNum2.toFloat(), masterStuNum2.toString() + "人")
                            entries.add(pieEntry2)
                        }

                        colors[3] = Color.parseColor("#00afff")
                        colorSum.add(Color.parseColor("#00afff"))
                        val pieEntry3 = PieEntry(0.01f, "")
                        entries.add(pieEntry3)

                        if (entries.size != 0) {

                            val masterName0 = classGrammarDiagnosisInfor!!.GrammarMap[0].MasterName
                            val subsetName0 = classGrammarDiagnosisInfor!!.GrammarMap[0].SubsetName
                            val masterName1 = classGrammarDiagnosisInfor!!.GrammarMap[1].MasterName
                            val subsetName1 = classGrammarDiagnosisInfor!!.GrammarMap[1].SubsetName
                            val masterName2 = classGrammarDiagnosisInfor!!.GrammarMap[2].MasterName
                            val subsetName2 = classGrammarDiagnosisInfor!!.GrammarMap[2].SubsetName

                            pieChartEntity = PieChartView(rootView!!.PieChart, entries,
                                    arrayOf(masterName0, masterName1, masterName2),
                                    arrayOf(subsetName0, subsetName1, subsetName2),
                                    colors, colorSum, 8f, PieDataSet.ValuePosition.OUTSIDE_SLICE)
                            pieChartEntity!!.setHoleEnabled(Color.WHITE, 75f, Color.WHITE, 80f)
                            pieChartEntity!!.setLegendEnabled(false)
                            pieChartEntity!!.setPercentValues(true)
                            pieChartEntity!!.setOnItemClickListener {
                                when (it) {
                                    0 -> {
//                                        if (isPieFirstSelected) {
//                                            MyToast.showToast("黄---取消选中")
//                                        } else {
//                                            MyToast.showToast("黄---选中")
//                                        }
                                        isPieFirstSelected = !isPieFirstSelected
                                        isPieSecondSelected = false
                                        isPieThirdSelected = false

                                        showGrammarDialogView(0)
                                    }
                                    1 -> {
//                                        if (isPieSecondSelected) {
//                                            MyToast.showToast("绿---取消选中")
//                                        } else {
//                                            MyToast.showToast("绿---选中")
//                                        }
                                        isPieSecondSelected = !isPieSecondSelected
                                        isPieThirdSelected = false
                                        isPieFirstSelected = false

                                        showGrammarDialogView(1)
                                    }
                                    2 -> {
//                                        if (isPieThirdSelected) {
//                                            MyToast.showToast("蓝---取消选中")
//                                        } else {
//                                            MyToast.showToast("蓝---选中")
//                                        }
                                        isPieThirdSelected = !isPieThirdSelected
                                        isPieSecondSelected = false
                                        isPieFirstSelected = false

                                        showGrammarDialogView(2)
                                    }
                                    5 -> {
//                                        MyToast.showToast("全部取消选中状态---点击")
                                        isPieFirstSelected = false
                                        isPieSecondSelected = false
                                        isPieThirdSelected = false
                                    }
                                }
                            }
                        }

                        initPieViewData()

                        LlGrammarMasterView.visibility = View.VISIBLE
                        LlGrammarMasterEmptyView.visibility = View.GONE
                    } else {
                        MyToast.showToast(it.message)
                        LlGrammarMasterView.visibility = View.GONE
                        LlGrammarMasterEmptyView.visibility = View.VISIBLE
                    }
                }, {
                    MyToast.showToast(it.message)
                    LlGrammarMasterView.visibility = View.GONE
                    LlGrammarMasterEmptyView.visibility = View.VISIBLE
                })

    }

    private var isPieFirstSelected = false
    private var isPieSecondSelected = false
    private var isPieThirdSelected = false

    private fun initPieViewData() {
        rootView!!.MyPieViewBottom.setColors(createColors())
        rootView!!.MyPieViewBottom.setData(createData())
    }

    private fun createData(): ArrayList<MyPieEntry>? {
        val masterStuNum0 = classGrammarDiagnosisInfor!!.GrammarMap[0].MasterStuNum
        val masterStuNum1 = classGrammarDiagnosisInfor!!.GrammarMap[1].MasterStuNum
        val masterStuNum2 = classGrammarDiagnosisInfor!!.GrammarMap[2].MasterStuNum
        val masterStuNumAll = masterStuNum0 + masterStuNum1 + masterStuNum2

        val percentage0 = LancooMethod.getCorrectRate(masterStuNum0.toDouble(), masterStuNumAll.toDouble()) //这样还是不能解决商保持两位小数
        val percentage1 = LancooMethod.getCorrectRate(masterStuNum1.toDouble(), masterStuNumAll.toDouble())
        val percentage2 = LancooMethod.getCorrectRate(masterStuNum2.toDouble(), masterStuNumAll.toDouble())

        val pieLists: ArrayList<MyPieEntry> = ArrayList<MyPieEntry>()
        pieLists.add(MyPieEntry((percentage0 * 100).toFloat(), "0%~60%", "语法掌握率", masterStuNum0.toString() + "人"))
        pieLists.add(MyPieEntry((percentage1 * 100).toFloat(), "60%~80%", "语法掌握率", masterStuNum1.toString() + "人"))
        pieLists.add(MyPieEntry((percentage2 * 100).toFloat(), "80%~100%", "语法掌握率", masterStuNum2.toString() + "人"))
        return pieLists
    }

    private fun createColors(): ArrayList<Int>? {
        val colorLists = ArrayList<Int>()
        colorLists.add(Color.parseColor("#f9ad4f"))
        colorLists.add(Color.parseColor("#22d7bb"))
        colorLists.add(Color.parseColor("#00afff"))
        return colorLists
    }

    //词汇认知弹窗界面
    private fun showGrammarDialogView(flag: Int) {
        mViewModel.getRangeClassGrammarInfo_App(flag, zsdArea)
                .doOnSubscribe {
                }.bindLifeCycle(this)
                .subscribe({
                    if (it.code == 1) {
                        classGrammarMasterDistribInfor = it.data
//
                        val dialogGrammarMasterDistribList = DialogGrammarMasterDistribList(activity, flag, classGrammarMasterDistribInfor!!)
                        dialogGrammarMasterDistribList.setClickListener(object : DialogGrammarMasterDistribList.OnClickListener {
                            override fun onClick(pos: Int) {
                                startActivity(Intent(requireContext(), StuDiagnosisActivity::class.java).apply {
                                    putExtra("zsdarea", zsdArea)
                                    putExtra("number", zsdNumber.toString())
                                    putExtra("stuId", classGrammarMasterDistribInfor!!.ClassTopicTable[pos - 1].StuID)
                                    putExtra("moveTo", 1)// 0词汇认知 1语法认知 2:认知指数
                                })
                            }

                            override fun onDialogDismiss() {
                                pieChartEntity!!.refreshPie()
                            }
                        })
                        dialogGrammarMasterDistribList.show()
                    } else {
                        MyToast.showToast(it.message)
                    }
                }, {
                    MyToast.showToast(it.message)
                })
    }

    //语言能力弹窗界面
    private fun showLanguageAbailityDialogView(abailityName: String) {
        mViewModel.getAbilityForClass_App(abailityName)
                .doOnSubscribe {
                }.bindLifeCycle(this)
                .subscribe({
                    if (it.code == 1) {
                        classStuLanguageAbilityInfor = it.data

                        val dialogLanguageDiagnosisAbailityList = DialogLanguageDiagnosisAbailityList(activity, classStuLanguageAbilityInfor!!)
                        dialogLanguageDiagnosisAbailityList.show()
                    } else {
                        MyToast.showToast(it.message)
                    }
                }, {
                    MyToast.showToast(it.message)
                })
    }

    //语言能力主界面
    private fun showLanguageAbilityView() {

        mViewModel.getLanguageForClass_App()
                .doOnSubscribe {
                }.bindLifeCycle(this)
                .subscribe({
                    if (it.code == 1) {
                        classLanguageAbilityInfor = it.data

                        //显示语言能力分布图
                        var languageAbilityRank = ""
                        val conclusion = classLanguageAbilityInfor!!.Comprehensive.Conclusion
                        if (conclusion == 0) {
                            languageAbilityRank = "暂无诊断结果"
                        } else if (conclusion == 1) {
                            languageAbilityRank = "较差"
                        } else if (conclusion == 2) {
                            languageAbilityRank = "一般"
                        } else if (conclusion == 3) {
                            languageAbilityRank = "较好"
                        }
                        rootView!!.TvTitleLanguageAbility.text =
                                Html.fromHtml(resources.getString(R.string.aibk_class_language_abaility_diagnosis,
                                        languageAbilityRank))

                        var maxDistreNum = 0
                        val goodStuNum = classLanguageAbilityInfor!!.Comprehensive.GoodStuNum
                        val generalStuNum = classLanguageAbilityInfor!!.Comprehensive.GeneralStuNum
                        val badStuNum = classLanguageAbilityInfor!!.Comprehensive.BadStuNum
                        if (maxDistreNum < goodStuNum) {
                            maxDistreNum = goodStuNum
                        }
                        if (maxDistreNum < generalStuNum) {
                            maxDistreNum = generalStuNum
                        }
                        if (maxDistreNum < badStuNum) {
                            maxDistreNum = badStuNum
                        }
                        if (maxDistreNum <= 4) {
                            maxDistreNum = 4
                        } else {
                            maxDistreNum = (maxDistreNum / 4) * 4 + 4
                        }
                        rootView!!.TvLanguageAbailityScore0.text = ((maxDistreNum / 4) * 0).toString()
                        rootView!!.TvLanguageAbailityScore1.text = ((maxDistreNum / 4) * 1).toString()
                        rootView!!.TvLanguageAbailityScore2.text = ((maxDistreNum / 4) * 2).toString()
                        rootView!!.TvLanguageAbailityScore3.text = ((maxDistreNum / 4) * 3).toString()
                        rootView!!.TvLanguageAbailityScore4.text = ((maxDistreNum / 4) * 4).toString()

                        var manager5 = LinearLayoutManager(activity)
                        manager5.orientation = LinearLayoutManager.HORIZONTAL
                        rootView!!.RvLanguageAbility.layoutManager = manager5
                        val mAdapter5 = AibkLanguageAbilityAdapter(activity, classLanguageAbilityInfor!!, maxDistreNum)
                        mAdapter5.setClickListener(object : AibkLanguageAbilityAdapter.OnClickListener {
                            override fun onClick(pos: Int) {
                                var abailityId = ""
                                if (pos == 0) {
                                    abailityId = "TL"
                                } else if (pos == 1) {
                                    abailityId = "KY"
                                } else if (pos == 2) {
                                    abailityId = "YD"
                                } else if (pos == 3) {
                                    abailityId = "XZ"
                                }
                                showLanguageAbailityDialogView(abailityId)
                            }

                        })
                        rootView!!.RvLanguageAbility.adapter = mAdapter5
                    } else {
                        MyToast.showToast(it.message)
                    }
                }, {
                    MyToast.showToast(it.message)
                })


    }

    //做题特点主界面
    private fun showAnswerTraitView() {

        mViewModel.getClassExerciseTrait_App()
                .doOnSubscribe {
                }.bindLifeCycle(this)
                .subscribe({
                    if (it.code == 1) {
                        classAnswertraitInfor = it.data

                        val stuAvgRightRate = classAnswertraitInfor!!.StuAvgRightRate
                        val stuAvgRightUp = classAnswertraitInfor!!.StuAvgRightUp

                        rootView!!.TvRightRate.text = Html.fromHtml(
                                resources.getString(R.string.aibk_class_study_average_right_rate,
                                        (stuAvgRightRate * 100).toInt().toString() + "%"))

                        var stuAvgRightChangeTxt = ""
                        var stuAvgRightChangeNum = ""
                        if (stuAvgRightUp == 0.0) {
                            rootView!!.IvRightRateChange.setImageResource(R.mipmap.aibk_icon_right_rate_no_change)
                            stuAvgRightChangeTxt = "无变化"
                            rootView!!.TvRightRateChange.text = Html.fromHtml(
                                    resources.getString(R.string.aibk_class_study_average_right_rate_change_no,
                                            stuAvgRightChangeTxt))
                        } else if (stuAvgRightUp < 0) {
                            rootView!!.IvRightRateChange.setImageResource(R.mipmap.aibk_icon_right_rate_down)
                            stuAvgRightChangeTxt = "降低了"
                            stuAvgRightChangeNum = "" + Math.abs(stuAvgRightUp * 100).toInt() + "%"
                            rootView!!.TvRightRateChange.text = Html.fromHtml(
                                    resources.getString(R.string.aibk_class_study_average_right_rate_change_down,
                                            stuAvgRightChangeTxt, stuAvgRightChangeNum))
                        } else if (stuAvgRightUp > 0) {
                            rootView!!.IvRightRateChange.setImageResource(R.mipmap.aibk_icon_right_rate_up)
                            stuAvgRightChangeTxt = "提升了"
                            stuAvgRightChangeNum = "" + Math.abs(stuAvgRightUp * 100).toInt() + "%"
                            rootView!!.TvRightRateChange.text = Html.fromHtml(
                                    resources.getString(R.string.aibk_class_study_average_right_rate_change_up,
                                            stuAvgRightChangeTxt, stuAvgRightChangeNum))
                        }

                        /***********警戒线*****************/
                        val picketPoint = (stuAvgRightRate * 100).toInt()
                        rootView!!.TvpicketPoint.text = "$picketPoint%"
                        val params = rootView!!.LlPicketLine.layoutParams as RelativeLayout.LayoutParams
                        params.setMargins(0, DensityUtils.dp2px(activity, (100 - picketPoint) * 2f + 6f), 0, 0)
                        rootView!!.LlPicketLine.layoutParams = params
                        /***********柱状图*****************/
                        var manager6 = LinearLayoutManager(activity)
                        manager6.orientation = LinearLayoutManager.HORIZONTAL
                        rootView!!.RvAnswerTrait.layoutManager = manager6
                        val mAdapter6 = AibkAnswerTraitAdapter(activity, picketPoint, classAnswertraitInfor!!)
                        mAdapter6.setClickListener(object : AibkAnswerTraitAdapter.OnClickListener {
                            override fun onClick(genreName: String, typeRightRate: String, x: Int, y: Int) {
                                MyToast.showToast("$genreName:$typeRightRate%",
                                        x - DensityUtils.getScreenWidth(activity) / 2, y)
                            }
                        })
                        rootView!!.RvAnswerTrait.adapter = mAdapter6
                    } else {
                        MyToast.showToast(it.message)
                    }
                }, {
                    MyToast.showToast(it.message)
                })
    }

    //学习特点主界面
    private fun showStudyFeature() {
        mViewModel.getStudyFeatureForClass_App()
                .doOnSubscribe {
                }.bindLifeCycle(this)
                .subscribe({
                    if (it.code == 1) {
                        classStudyFeature = it.data

                        val studyTimeSize = classStudyFeature!!.StudyTime.size
                        if(studyTimeSize == 0) {
                            rootView!!.LlStudyLengthView.visibility = View.GONE
                            rootView!!.TvStudyLengthEmptyView.visibility = View.VISIBLE
                        }else {
                            rootView!!.LlStudyLengthView.visibility = View.VISIBLE
                            rootView!!.TvStudyLengthEmptyView.visibility = View.GONE
                            //学习特点：学习时长
                            mLineChartTimeManager = LineChartTimeManager(rootView!!.LineChart1)
                            //展示图表
                            mLineChartTimeManager!!.showLineChart(context, classStudyFeature, "年级优秀学生", resources.getColor(R.color.lancoooGreen))
                            mLineChartTimeManager!!.addLine(context, classStudyFeature, "班级学生", resources.getColor(R.color.lancoooBlue))
//                        //MarkerView
                            mLineChartTimeManager!!.setMarkerView(context, "min")
                        }

                        val studySpeedSize = classStudyFeature!!.StudySpeed.size
                        if(studySpeedSize == 0) {
                            rootView!!.LlStudySpeedView.visibility = View.GONE
                            rootView!!.TvStudySpeedEmptyView.visibility = View.VISIBLE
                        }else {
                            rootView!!.LlStudySpeedView.visibility = View.VISIBLE
                            rootView!!.TvStudySpeedEmptyView.visibility = View.GONE
                            //学习特点：学习速度
                            mLineChartSpeedManager = LineChartSpeedManager(rootView!!.LineChart2)
                            //展示图表
                            mLineChartSpeedManager!!.showLineChart(context, classStudyFeature, "年级优秀学生", resources.getColor(R.color.lancoooGreen))
                            mLineChartSpeedManager!!.addLine(context, classStudyFeature, "班级学生", resources.getColor(R.color.lancoooBlue))
//                        //MarkerView
                            mLineChartSpeedManager!!.setMarkerView(context, "")
                        }
                    } else {
                        MyToast.showToast(it.message)
                    }
                }, {
                    MyToast.showToast(it.message)
                })
    }

    //班级学习建议主界面
    private fun showStudyAdviceView() {
        mViewModel.getClassStudyAdvice_App(zsdArea)
                .doOnSubscribe {
                }.bindLifeCycle(this)
                .subscribe({
                    if (it.code == 1) {
                        classStudyAdviceInfor = it.data

                        //建议学习：词汇
                        var conclusionCH = classStudyAdviceInfor!!.ClassVocabulary.Conclusion
                        var starCH = classStudyAdviceInfor!!.ClassVocabulary.Star
                        var masteryRateCH = classStudyAdviceInfor!!.ClassVocabulary.MasteryRate

//                        conclusionCH = 1//测试使用
//                        starCH = 3 //测试使用
//                        masteryRateCH = 0.65//测试使用

                        if (conclusionCH == 1) {
                            //给出建议
                            rootView!!.RlAdviceViewCH.visibility = View.VISIBLE

                            var strRankCH = ""
                            if (masteryRateCH >= 0.6) {
                                strRankCH = "较低"
                            } else if (masteryRateCH >= 0.4 && masteryRateCH < 0.6) {
                                strRankCH = "一般"
                            } else if (masteryRateCH > 0 && masteryRateCH < 0.4) {
                                strRankCH = "较好"
                            }
                            rootView!!.TvAdviceContentCH.text =
                                    Html.fromHtml(resources.getString(R.string.aibk_class_study_advice_ch,
                                            strRankCH,
                                            LancooMethod.killlingDouble(LancooMethod.formatDouble(masteryRateCH, 3) * 100) + "%"))
                            rootView!!.RatingBarCH.isClickable = false
                            rootView!!.RatingBarCH.numStars = starCH
                            rootView!!.RatingBarCH.rating = starCH.toFloat()
                        } else {
                            rootView!!.RlAdviceViewCH.visibility = View.GONE
                        }
                        //建议学习：语法
                        var conclusionYF = classStudyAdviceInfor!!.ClassGrammar.Conclusion
                        var starYF = classStudyAdviceInfor!!.ClassGrammar.Star
                        val classGramAvgMasterRate = classStudyAdviceInfor!!.ClassGrammar.ClassGramAvgMasterRate
                        var weakGrammarNumber = classStudyAdviceInfor!!.ClassGrammar.WeakGrammarNumber

//                        conclusionYF = 1//测试使用
//                        starYF = 3 //测试使用
//                        weakGrammarNumber = 3
//                        classStudyAdviceInfor!!.ClassGrammar.WeakGrammarList = listOf("AAA","VVV","GGGG")//测试使用

                        if (conclusionYF == 1) {
                            //给出建议
                            rootView!!.RlAdviceViewYF.visibility = View.VISIBLE

                            var weakGrammarAll = ""
                            val weakGrammarListSize = classStudyAdviceInfor!!.ClassGrammar.WeakGrammarList.size
                            outLoop@ for (i in 0 until weakGrammarListSize) {
                                if (i <= 1) {
                                    val weakGrammar = classStudyAdviceInfor!!.ClassGrammar.WeakGrammarList[i]
                                    if (weakGrammarAll.isEmpty()) {
                                        weakGrammarAll = weakGrammar
                                    } else {
                                        weakGrammarAll = "$weakGrammarAll、$weakGrammar" + "等"
                                    }
                                } else {
                                    break@outLoop
                                }
                            }
                            rootView!!.TvAdviceContentYF.text =
                                    Html.fromHtml(resources.getString(R.string.aibk_class_study_advice_yf,
                                            LancooMethod.killlingDouble(classGramAvgMasterRate) + "%",
                                            weakGrammarAll,
                                            weakGrammarNumber))
                            rootView!!.RatingBarYF.isClickable = false
                            rootView!!.RatingBarYF.numStars = starYF
                            rootView!!.RatingBarYF.rating = starYF.toFloat()
                        } else {
                            rootView!!.RlAdviceViewYF.visibility = View.GONE
                        }
                        //建议学习：题型
                        val conclusionTX = classStudyAdviceInfor!!.ClassQType.Conclusion
                        val starTX = classStudyAdviceInfor!!.ClassQType.Star
                        var weakTypeList = classStudyAdviceInfor!!.ClassQType.WeakTypeList
                        val weakTypeNumber = classStudyAdviceInfor!!.ClassQType.WeakTypeNumber
                        if (conclusionTX == 1) {
                            //给出建议
                            rootView!!.RlAdviceViewTX.visibility = View.VISIBLE

                            if (weakTypeNumber > 2) {
                                weakTypeList = getStr(weakTypeList, 2, "、") + "等"
                            }
                            rootView!!.TvAdviceContentTX.text =
                                    Html.fromHtml(resources.getString(R.string.aibk_class_study_advice_tx, weakTypeList, weakTypeNumber))
                            rootView!!.RatingBarTX.isClickable = false
                            rootView!!.RatingBarTX.numStars = starTX
                            rootView!!.RatingBarTX.rating = starTX.toFloat()
                        } else {
                            rootView!!.RlAdviceViewTX.visibility = View.GONE
                        }
                        //建议学习：难题
                        val conclusionNT = classStudyAdviceInfor!!.ClassWrongQues.Conclusion
                        val starNT = classStudyAdviceInfor!!.ClassWrongQues.Star
                        val aLLQuesNum = classStudyAdviceInfor!!.ClassWrongQues.ALLQuesNum
                        val wrongNumber = classStudyAdviceInfor!!.ClassWrongQues.WrongNumber
                        if (conclusionNT == 1) {
                            //给出建议
                            rootView!!.RlAdviceViewNT.visibility = View.VISIBLE

                            rootView!!.TvAdviceContentNT.text =
                                    Html.fromHtml(resources.getString(R.string.aibk_class_study_advice_nt, wrongNumber))
                            rootView!!.RatingBarNT.isClickable = false
                            rootView!!.RatingBarNT.numStars = starNT
                            rootView!!.RatingBarNT.rating = starNT.toFloat()
                        } else {
                            rootView!!.RlAdviceViewNT.visibility = View.GONE
                        }
                        //建议学习：能力
                        val starNL = classStudyAdviceInfor!!.ClassWeakSkill.Star
                        val weakSkillTL = classStudyAdviceInfor!!.ClassWeakSkill.TL//1不薄弱，2薄弱
                        val weakSkillKY = classStudyAdviceInfor!!.ClassWeakSkill.KY
                        val weakSkillYD = classStudyAdviceInfor!!.ClassWeakSkill.YD
                        val weakSkillXZ = classStudyAdviceInfor!!.ClassWeakSkill.XZ
                        var weakSkillAll = ""
                        if (weakSkillTL == 2) {
                            weakSkillAll = "听力"
                        }
                        if (weakSkillKY == 2) {
                            if (weakSkillAll.isEmpty()) {
                                weakSkillAll = "口语"
                            } else {
                                weakSkillAll = "$weakSkillAll、口语"
                            }
                        }
                        if (weakSkillYD == 2) {
                            if (weakSkillAll.isEmpty()) {
                                weakSkillAll = "阅读"
                            } else {
                                weakSkillAll = "$weakSkillAll、阅读"
                            }
                        }
                        if (weakSkillXZ == 2) {
                            if (weakSkillAll.isEmpty()) {
                                weakSkillAll = "写作"
                            } else {
                                weakSkillAll = "$weakSkillAll、写作"
                            }
                        }

                        rootView!!.TvAdviceContentNL.text =
                                Html.fromHtml(resources.getString(R.string.aibk_class_study_advice_nl, weakSkillAll, weakSkillAll))
                        rootView!!.RatingBarNL.isClickable = false
                        rootView!!.RatingBarNL.numStars = starNL
                        rootView!!.RatingBarNL.rating = starNL.toFloat()

                        //建议学习：学习方法
                        val studyTimeIsCons = classStudyAdviceInfor!!.ClassMethodOfStudy.StudyTime.IsCons
                        val studyTimeAdviceName = classStudyAdviceInfor!!.ClassMethodOfStudy.StudyTime.AdviceName
                        val studyTimeConclusion = classStudyAdviceInfor!!.ClassMethodOfStudy.StudyTime.Conclusion
                        val time = classStudyAdviceInfor!!.ClassMethodOfStudy.StudyTime.Time
                        val studyEfficiencyIsCons = classStudyAdviceInfor!!.ClassMethodOfStudy.StudyEfficiency.IsCons
                        val studyEfficiencyAdviceName = classStudyAdviceInfor!!.ClassMethodOfStudy.StudyEfficiency.AdviceName
                        val studyEfficiencyConclusion = classStudyAdviceInfor!!.ClassMethodOfStudy.StudyEfficiency.Conclusion
                        val wrongRateIsCons = classStudyAdviceInfor!!.ClassMethodOfStudy.WrongRate.IsCons
                        val wrongRateAdviceName = classStudyAdviceInfor!!.ClassMethodOfStudy.WrongRate.AdviceName
                        val wrongRateConclusion = classStudyAdviceInfor!!.ClassMethodOfStudy.WrongRate.Conclusion

                        if (studyTimeIsCons) {
                            rootView!!.TvAdviceContentXXFF1.visibility = View.VISIBLE
                            rootView!!.TvAdviceContentXXFF1.text =
                                    Html.fromHtml(resources.getString(R.string.aibk_class_study_advice_xxff1,
                                            "学习时长较短", time + "小时"))
                        } else {
                            rootView!!.TvAdviceContentXXFF1.visibility = View.GONE
                        }
                        if (studyEfficiencyIsCons) {
                            rootView!!.TvAdviceContentXXFF2.visibility = View.VISIBLE
                            rootView!!.TvAdviceContentXXFF2.text =
                                    Html.fromHtml(resources.getString(R.string.aibk_class_study_advice_xxff2,
                                            "学习效率较低"))
                        } else {
                            rootView!!.TvAdviceContentXXFF2.visibility = View.GONE
                        }
                        if (wrongRateIsCons) {
                            rootView!!.TvAdviceContentXXFF3.visibility = View.VISIBLE
                            rootView!!.TvAdviceContentXXFF3.text =
                                    Html.fromHtml(resources.getString(R.string.aibk_class_study_advice_xxff3,
                                            "做题较马虎", "认真审题、仔细答题"))
                        } else {
                            rootView!!.TvAdviceContentXXFF3.visibility = View.GONE
                        }

                        LlStudyAdvicView.visibility = View.VISIBLE
                        LlStudyAdviceEmptyView.visibility = View.GONE
                    } else {
                        MyToast.showToast(it.message)
                        LlStudyAdvicView.visibility = View.GONE
                        LlStudyAdviceEmptyView.visibility = View.VISIBLE
                    }
                }, {
                    MyToast.showToast(it.message)
                    LlStudyAdvicView.visibility = View.GONE
                    LlStudyAdviceEmptyView.visibility = View.VISIBLE
                })
    }

    private fun getStr(str: String, n: Int, strFlag: String): String {
        var i = 0
        var s = 0
        while (i++ < n) {
            s = str.indexOf(strFlag, s + 1)
            if (s == -1) {
                return str
            }
        }
        return str.substring(0, s)
    }

    //点击事件
    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.TvKnowledgeAreaCount -> {
                //选择切换知识点域数据
                if (classKnowledgeAreaInfor!!.size > 0) {
                    val dialogChangeKnowledgeArea = DialogChangeKnowledgeArea(activity, classKnowledgeAreaInfor!!)
                    dialogChangeKnowledgeArea.setClickListener(object : DialogChangeKnowledgeArea.OnClickListener {
                        override fun onClickWhich(pos: Int) {

                            /**********************选择知识点域后刷新相应图表************************************/
                            //显示认知指数模块内容
                            showCognitiveDiagnosisView()
                            //显示词汇认知主界面模块内容
                            showVocablaryDiagnosisView()
                            //语法认知主界面
                            showGrammarDiagnosisView()
                            //班级学习建议
                            showStudyAdviceView()
                        }
                    })
                    dialogChangeKnowledgeArea.show()
                } else {
                    MyToast.showToast("未获取到知识点域相关信息,请稍后重试!")
                }
            }
            R.id.TvCognitiveDiagnosisPersonal -> {
                startActivity(Intent(requireContext(), StuDiagnosisActivity::class.java).apply {
                    putExtra("zsdarea", zsdArea)
                    putExtra("number", zsdNumber.toString())
                    putExtra("stuId", "")
                })
            }
            R.id.BtnGoToStuRzzd -> {
//                MyToast.showToast("当班级认知诊断为空的时候，跳转到学生个人诊断报告!")
                mViewModel.getZsdArea_App()
                        .doOnSubscribe {
                        }.bindLifeCycle(this)
                        .subscribe({
                            if (it.code == 1) {
                                classKnowledgeAreaInfor = it.data

                                zsdNumber = classKnowledgeAreaInfor!![0].Number
                                startActivity(Intent(requireContext(), StuDiagnosisActivity::class.java).apply {
                                    putExtra("zsdarea", zsdArea)
                                    putExtra("number", zsdNumber.toString())
                                    putExtra("stuId", "")
                                })
                            } else {
//                        MyToast.showToast(it.message)
                            }
                        }, {
//                    MyToast.showToast(it.message)
                        })
            }
            R.id.IvExplainYgcj -> {
                if (Ext.GLOBAL_GRADE_STU == "K6" ||Ext.GLOBAL_GRADE_STU == "K7" || Ext.GLOBAL_GRADE_STU == "K8" || Ext.GLOBAL_GRADE_STU == "K9") {
                    Ext.STAGE_NO = "B"
                } else if (Ext.GLOBAL_GRADE_STU == "K10" || Ext.GLOBAL_GRADE_STU == "K11" || Ext.GLOBAL_GRADE_STU == "K12") {
                    Ext.STAGE_NO = "C"
                }
                var explainContent = ""
                if (Ext.STAGE_NO == "B") {
                    explainContent = resources.getString(R.string.aibk_explain_ygcj, "中考")
                } else if (Ext.STAGE_NO == "C") {
                    explainContent = resources.getString(R.string.aibk_explain_ygcj, "高考")
                }
                val dialogExplain = DialogExplain(activity, explainContent)
                dialogExplain.show()
            }
            R.id.RlAverageGradeChangeUpView -> {
                showDialogStuScoreNumUpDownInfor(true)
            }
            R.id.RlAverageGradeChangeDownView -> {
                showDialogStuScoreNumUpDownInfor(false)
            }
            R.id.IvExplainRzzs -> {
                if (classCognitiveDiagnosisInfor != null) {
                    val fullIndex = classCognitiveDiagnosisInfor!!.FullIndex
                    val explainContent = resources.getString(R.string.aibk_explain_rzzs, LancooMethod.killlingDouble(fullIndex))
                    val dialogExplain = DialogExplain(activity, explainContent)
                    dialogExplain.show()
                } else {
                    MyToast.showToast("未获取到相关认知指数信息，请稍后重试！")
                }
            }
            R.id.IvHonorRoll -> {
                //显示认知荣誉榜弹窗
                if (!ButtonUtils.isFastDoubleClick(R.id.IvHonorRoll)) {
                    showDialogStuHonorRollList()
                }
            }
            R.id.RlCognitionChangeUpView -> {
                showDialogStuCognitionNumUpDownInfor(9)
            }
            R.id.RlCognitionChangeDownView -> {
                showDialogStuCognitionNumUpDownInfor(10)
            }
            R.id.IvExplainChrz -> {
                val explainContent = "基于学生各词汇知识点历次学习轨迹，实时评估出学生词汇的认知情况。"
                val dialogExplain = DialogExplain(activity, explainContent)
                dialogExplain.show()
            }
            R.id.IvExplainYfrz -> {
                val explainContent = "基于学生各语法知识点历次学习轨迹，实时评估出学生语法的认知情况。"
                val dialogExplain = DialogExplain(activity, explainContent)
                dialogExplain.show()
            }
            R.id.IvExplainYynl -> {
                val explainContent = "基于学生各种能力的做题正确率及词汇、语法认知情况，大数据分析学生听、说、读、写的能力水平以及每种能力的掌握速度。"
                val dialogExplain = DialogExplain(activity, explainContent)
                dialogExplain.show()
            }
            R.id.IvExplainZttd -> {
                val explainContent = "基于学生的做题情况，从认真度及易错题型等角度，统计分析学生的错题错因。"
                val dialogExplain = DialogExplain(activity, explainContent)
                dialogExplain.show()
            }
            R.id.IvExplainXxtd -> {
                val explainContent = "从学习时长及知识掌握速度两个维度分析学生的日常学习习惯。"
                val dialogExplain = DialogExplain(activity, explainContent)
                dialogExplain.show()
            }
            R.id.BtnStudyLength -> {
                if (rootView!!.RlStudyLengthView.visibility == View.GONE) {
                    rootView!!.BtnStudyLength.isSelected = true
                    rootView!!.BtnStudySpeed.isSelected = false
                    showAnim(rootView!!.RlStudyLengthView)
                    hideAnim(rootView!!.RlStudySpeedView)
                }
            }
            R.id.BtnStudySpeed -> {
                if (rootView!!.RlStudySpeedView.visibility == View.GONE) {
                    rootView!!.BtnStudyLength.isSelected = false
                    rootView!!.BtnStudySpeed.isSelected = true
                    showAnim(rootView!!.RlStudySpeedView)
                    hideAnim(rootView!!.RlStudyLengthView)
                }
            }
        }
    }

    private fun showAnim(mRl: RelativeLayout) {
        val ctrlAnimation = TranslateAnimation(
                TranslateAnimation.RELATIVE_TO_SELF, 1f, TranslateAnimation.RELATIVE_TO_SELF, 0f,
                TranslateAnimation.RELATIVE_TO_SELF, 0f, TranslateAnimation.RELATIVE_TO_SELF, 0f)
        ctrlAnimation.duration = 400L //设置动画的过渡时间
        mRl.postDelayed(Runnable {
            mRl.visibility = View.VISIBLE
            mRl.startAnimation(ctrlAnimation)
        }, 100)
    }

    private fun hideAnim(mRl: RelativeLayout) {
        val ctrlAnimation = TranslateAnimation(
                TranslateAnimation.RELATIVE_TO_SELF, 0f, TranslateAnimation.RELATIVE_TO_SELF, 1f,
                TranslateAnimation.RELATIVE_TO_SELF, 0f, TranslateAnimation.RELATIVE_TO_SELF, 0f)
        ctrlAnimation.duration = 400L //设置动画的过渡时间
        mRl.postDelayed(Runnable {
            mRl.visibility = View.GONE
            mRl.startAnimation(ctrlAnimation)
        }, 100)
    }

    override fun setMenuVisibility(menuVisible: Boolean) {
        super.setMenuVisibility(menuVisible)
        if (menuVisible) {
            //当其他模块切换班级后，当前模块进行班级显示刷新
            rootView!!.TvCourseClass.text = Ext.COURSE_CLASSNAME
            rootView!!.TvClassDiagnosisName.text = Ext.COURSE_CLASSNAME +"认知诊断报告"
        }

    }

}